import { PREFIX_CHAT } from '@/const'
import request from '@/utils/request'
export interface IResponse<T = any> {
  code: number
  entity: T
  message: string
  ok: boolean
}

export interface IAnswer {
  answerContent: string
  answerId: string
  answerTimestamp: number
  createdTimestamp: number
  customerId: string
  duration: number
  externalUserId: number
  hasCleanLine: true
  hasDeleted: number
  hasShare: number
  hasSupport: number
  id: string
  questionContent: string
  questionId: string
  questionType: number
  questionUrl: string
  relatedArticles: [
    {
      authorName: string
      chatConversationArticleRelId: string
      content: string
      icon: string
      id: string
      isRelated: number
      splitId: string
    }
  ]
  suggestQuestionList: string[]
  resourceIds: string[]
  responseState: string
  sessionId: string
  supportUpdateTime: string
}
// const PREFIX_TREND = `/quotation`
const PREFIX_CUSTOMER = `/customer`
const PREFIX_INFORMATION = `/information`

// const PREFIX_UPAS = `/upas`
// const PREFIX_BS = `/business-search`

/**************************** 公共接口 start ******************************/

// 登录接口
export const apiLogin = (params = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/wx/applet/getToken`,
    method: `POST`,
    params
  })
}

// 退出登录
export const apiLogout = (params = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/login/loginOut`,
    method: `GET`,
    params
  })
}

// 注册接口
export const apiRegister = (params = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/wx/applet/login`,
    method: `POST`,
    params
  })
}

// 注销账户
export const apiLogoff = (params = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/login/cancellation`,
    method: `GET`,
    params
  })
}

// 获取用户信息
export const apiUserDetail = (params = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/user/detail`,
    method: `GET`,
    params
  })
}

// 修改用户信息
export const apiUserEdit = (data = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/user/edit`,
    method: `POST`,
    data
  })
}

//通过经纬度 获取所在城市
export const apiCityInfo = (params = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/wx/applet/location`,
    method: `POST`,
    params
  })
}

//上传文件
export const apiUpload = (data = {}) => {
  return request({
    url: PREFIX_CHAT + `/common/file/upload`,
    method: `POST`,
    data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

//当用户点击button(open-type = getPhoneNumber)在 @getphonenumber 回调中获取到code,拿这个code去跟后端获取phoneNubmer
export const apiPhoneNumber = (data = {}) => {
  return request({
    url: PREFIX_CUSTOMER + `/wx/applet/getPhoneNumberAndLogin`,
    method: `POST`,
    data
  })
}

// 事件 点赞、踩
export const apiNewsFeedback = (data = {}) => {
  return request({
    url: PREFIX_INFORMATION + `/support/update`,
    method: `POST`,
    data
  })
}

/**************************** 公共接口 end ******************************/

/**************************** 事件接口 start ******************************/

// import {
//   apiTrackOnload,
//   apiTrackArticleShare,
//   apiTrackEventShare,
//   apiTrackMorningShare,
//   apiTrackShare
// } from `./track`

// export {
//   apiTrackOnload,
//   apiTrackArticleShare,
//   apiTrackEventShare,
//   apiTrackMorningShare,
//   apiTrackShare
// }
